<?php
/**
 * @author Jumper Swordwave
 * date: 2021/04/19
 */
declare(strict_types=1);
namespace App\Game\Model;

use App\Game\Core\GameStatus;

/**
 * 用户
 * @property int    $id         用户id
 * @property int    $fd         用户连接
 * @property string $nickname   用户昵称
 * @property int    $status     用户状态
 * @property int    $room       用户房间id
 * @property int    $position   用户房间位置
 * @property int    $updated_at 上次通信时间
 */
class User extends Base
{
    public function reset()
    {
        $this->status = GameStatus::USER_WAITING;
        $this->room = 0;
        $this->position = 0;
        $this->updated_at = time();
    }

    /**
     * 玩家是否就绪
     */
    public function isReady()
    {
        return $this->status == GameStatus::USER_READY;
    }
}